﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using YasharEl.Infrastructure.ObjectFactory;

namespace YasharEl.Infrastructure.Core.Prototype
{
    [ContractClass(typeof(PrototypeEntityContract))]
    public interface IPrototypeEntity
    {
        IList<IPropertyInstance> Properties { get; }

        IPropertyInstance StoreValue(string key, object value, IDependencyResolver resolver);
    }

    [ContractClassFor(typeof(IPrototypeEntity))]
    internal abstract class PrototypeEntityContract : IPrototypeEntity
    {
        #region IPrototypeEntity Members

        public IList<IPropertyInstance> Properties
        {
            get { return new List<IPropertyInstance>(); }
        }

        public IPropertyInstance StoreValue(string key, object value, IDependencyResolver resolver)
        {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(key), "key could not be null or empty.");
            Contract.Requires<ArgumentNullException>(resolver != null, "resolver could not be null.");

            return default(IPropertyInstance);
        }

        #endregion
    }
}
